<!DOCTYPE html>
<html
        xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
        layout:decorate="~{base/layout}">
<div layout:fragment="content">
    <!--header wrapper end-->
    <!--med_tittle_section-->
    <div class="med_tittle_section">
        <div class="med_img_overlay"></div>
        <div class="container">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="med_tittle_cont_wrapper">
                        <div class="med_tittle_cont">
                            <ol class="breadcrumb">
                                <li><a th:href="@{/}">系统首页</a></li>
                                <li><a th:href="@{/strategy/travelStrategyListUI}">攻略列表</a></li>
                                <li><a href="#">预订</a></li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- med_tittle_section End -->
    <!--service section start-->
    <div class="page-container">
        <div class="container">
            <div class="row med_toppadder50 med_bottompadder50">
                <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                    <div class="news-detail-box">
                        <h3 th:text="${travelStrategy.title}"></h3>
                        <div class="author-info">
                            <span th:text="${#calendars.format(travelStrategy.createDate,'yyyy-MM-dd')}"></span>
                            <!--<span>所在地：<span th:text="${travelRoute.address}"></span></span>-->
                            <span>浏览次数：13</span>
                        </div>
                        <div class="news-detail-content">
                            <p th:text="${travelStrategy.describe}">
                            </p>
                            <div align="right" style="float:right">
                                <button th:if="${flag == false}" th:onclick="cancelTravelStrategyReserve([[${travelStrategy.id}]],'收藏')"
                                        type="button" class="btn btn-default btn-info">收藏
                                </button>
                                <button th:if="${flag == true }" th:onclick="cancelTravelStrategyReserve([[${travelStrategy.id}]],'取消收藏')"
                                        type="button" class="btn btn-default btn-info">
                                    取消收藏
                                </button>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                    <div class="sider-card">
                        <div class="sider-card-header">
                            <h3>热门攻略</h3>
                        </div>
                        <ul class="sider-list-model-a">
                            <li th:each="travelStrategy:${top10Strategy}">
                                <a th:href="@{/strategy/travelStrategyDetailsUI(id=${travelStrategy.id})}"
                                   th:text="${travelStrategy.title}">XXXX</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--service section end-->
    <script th:inline="javascript">
        function cancelTravelStrategyReserve(id, str) {
            $.ajax({
                url: '/travel/strategy/cancelTravelStrategyReserve',
                data: {"id": id},
                type: 'post',
                dataType: 'json',
                success: function (result) {
                    if (result.code === 200) {
                        if(str == '预订'){
                            confirm(str + "成功!"); //在页面上弹出对话框
                            window.location.href = "/travel/strategy/strategyManageUI";
                        }else{
                            confirm(str + "成功!"); //在页面上弹出对话框
                            window.location.href = "/travel/strategy/travelStrategyListUI";
                        }
                    } else {
                        layer.open({
                            title: '错误提示',
                            content: result.message
                        });
                    }
                }
            })
        }
    </script>
</div>
</html>